package com.xspace.android.xafcommon.network.message;

import com.xspace.android.xafcommon.network.task.HttpNormalTask;
import com.xspace.android.xafcommon.network.task.ITaskListener;
import com.xspace.android.xafcommon.network.task.TaskManager;

public abstract class ControlManage extends ADataFlowControl implements
		ITaskListener {
	protected SendRequestListener listener;

	public void addTask(ARequestMsg req, AResponseMsg resp) {
		if (super.isConnectInternet()) {
			HttpNormalTask task = new HttpNormalTask(req, resp, this);
			task.isBackgroud = req.isBackgroud;
			TaskManager.getInstance().addTask(task);
		} else {
			if (listener != null)
				listener.offline(resp.msgType);
		}
	}

	public void cancelTask(int serId) {
		TaskManager.getInstance().cancelTask(serId);
	}

	@Override
	public void notifyTask(IResponseMsg respMsg) {
		resultInfomation(respMsg);
	}

	public abstract void resultInfomation(IResponseMsg respMsg);

}
